﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

namespace QZoneMessage
{
    partial class AboutBox1 : Form
    {
        public AboutBox1()
        {
            InitializeComponent();
            this.Text = String.Format("关于 QQ空间留言器");
        }
        private void AboutBox1_Load(object sender, EventArgs e)
        {
            if (regedit.REGISTERED)
            {
                haveRegistered_label.Text = "已注册，感谢您的注册使用！";

                buyAuthCode_linkLabel.Visible = false;
                machineCode_label1.Visible = false;
                machineCode_textBox.Visible = false;
                registerCode_label.Visible = false;
                registerCode_textBox.Visible = false;
                registe_button.Visible = false;
            }
            else
            {
                machineCode_textBox.Text = regedit.Get_Harddisk_Serial();
            }
        }

        private void buyAuthCode_linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.buyAuthCode_linkLabel.LinkVisited = true;
            System.Diagnostics.Process.Start("http://item.taobao.com/item.htm?id=20019420881");
        }

        private void registe_button_Click(object sender, EventArgs e)
        {
            if (registerCode_textBox.Text != regedit.AuthCode)
            {
                MessageBox.Show("请输入正确的注册码！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                regedit.Write_Registration_Code(regedit.AuthCode);
                if (regedit.Read_Registration_Code() != regedit.AuthCode)
                {
                    MessageBox.Show("注册失败！请确认以管理员身份登录并且具有系统控制权限！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    regedit.REGISTERED = true;
                    regedit.VisitCount = 30000000;

                    MessageBox.Show("注册成功！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    haveRegistered_label.Text = "已注册，感谢您的注册使用！";

                    buyAuthCode_linkLabel.Visible = false;
                    machineCode_label1.Visible = false;
                    machineCode_textBox.Visible = false;
                    registerCode_label.Visible = false;
                    registerCode_textBox.Visible = false;
                    registe_button.Visible = false;
                }
            }
        }
    }
}
